<?php 
/**
 * 
 * Modelo de Tipo de Outbound
 * @author Natanael
 * 
 */
 
class mtipo_outbound extends Model{
	
	   private $mTableName = 'OB_TipoOutbound';
	
	   public function __construct()
	   {
	       parent::model();
	   }
	   
	   public function loadOutbound()
	   {
	   	  $result = $this->db->get_where($this->mTableName);
	   	  return $this->getArrayFromQueryResurt($result);
	   }
	   
	   public function loadOutboundById($id)
	   {
	   	  $result = $this->db->get_where($this->mTableName,array('IdOutbound'=>$id));
	   	  
	   	   if ($result->num_rows() == 0)
	   	   {
	   	   	 return false;
	   	   }
	   	   
	   	   return new tipoOutboundS($result->row());
	   	
	   } 
	   
	   private function getArrayFromQueryResurt($result)
	   {
	   	   if ($result->num_rows() == 0)
	   	      return false;
	   	      
	   	   $query_result = array();

	   	   foreach ($result->result() as $k)
	   	   {	
	   	   	   $query_result[] = new tipoOutboundS($k);
	   	   }
	   	   
	   	   return $query_result;
	   }
	   
	   public function addRegistro($data)
	   {
	      if ($this->db->insert($this->mTableName,$data))
	      {
	      	return true;
	      }
	      	  
	      	return false;  
	   }
	   
	   public function editRegistro($data, $id)
	   {
	   	  if ($this->db->update($this->mTableName,$data,array('IdOutbound'=>$id))) 
	   	  {
	   	      return true;
	   	  }
	   	  
	   	      return false;
	      	
	   }
	   
	   public function deleteRegistro($id)
	   {
	   	   if ($this->db->delete($this->mTableName,array('IdOutbound'=>$id))) 
	   	   {
	   	   	  return true;
	   	   }
	   	   
	   	      return false;
	   }
	   
	
}

class tipoOutboundS{
	   
	   private $idOutbound = 0;
	   private $tipoOutbound = "";
   
	   public function __construct($ojt)
	   {
	   	  $this->setIdOutbound($ojt->IdOutbound);
	   	  $this->setTipoOutbound($ojt->OutboundTipo);
	   }
	
	   public function setIdOutbound($ojt)
	   {
	   	  $this->idOutbound = $ojt;
	   }
	   
	   public function getIdOutbound()
	   {
	   	  return $this->idOutbound;	
	   }
	   
	   public function setTipoOutbound($ojt)  
	   {
	   	  $this->tipoOutbound = $ojt;
	   }
	   
	   public function getTipoOutbound()
	   {
	   	  return $this->tipoOutbound;
	   }
	   
}


?>